package cn.yujiago.miaosha.service.impl;

import cn.yujiago.miaosha.dto.GoodsDTO;
import cn.yujiago.miaosha.dto.Result;
import cn.yujiago.miaosha.entity.Goods;
import cn.yujiago.miaosha.mapper.GoodsMapper;
import cn.yujiago.miaosha.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    private GoodsMapper goodsMapper;

    @Override
    public GoodsDTO getGoodsDetail(Long goodsId) {

        return goodsMapper.selectGoodsById(goodsId);
    }

    @Override
    public List<GoodsDTO> getMiaoshaList() {

        List<GoodsDTO> list = goodsMapper.selectAllMiaoshaoGoods();

        return list;
    }

    @Override
    public GoodsDTO getGoodsDTOById(Long goodsId) {

        return goodsMapper.selectById(goodsId);
    }

    @Override
    public boolean reduceStock(GoodsDTO goods) {
        return goodsMapper.reduceStock(goods.getId());
    }

}
